<template>
  <el-form :model="formInline" class="zw-search-form" label-position="right" label-width="auto">
    <el-row class="el_filter_row" :gutter="20">
      <el-col :span="8">
        <el-form-item label="外部联系人权限">
          <el-select clearable v-model="formInline.is_follow_user" placeholder="请选择" class="form-label">
            <el-option v-for="item in memberList" :key="item.value" :label="item.label" :value="item.value"></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="成员姓名">
          <el-input v-model="formInline.name" suffix-icon="Search" placeholder="输入成员姓名" class="form-label"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="成员状态">
          <el-select clearable v-model="formInline.status" placeholder="请选择" class="form-label"> <el-option v-for="item in memberStatus" :key="item.value" :label="item.label" :value="item.value"></el-option> </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="成员类型">
          <el-select clearable v-model="formInline.is_local" placeholder="请选择" class="form-label"> <el-option v-for="item in memberType" :key="item.value" :label="item.label" :value="item.value"></el-option> </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item class="buttons">
          <zw-power :code="'CUSTOMER_KANBAN_CANCEL'">
            <el-button type="primary" @click="onSubmit('formInline')">查询</el-button>
          </zw-power>
          <el-button class="clear" @click="clearSearchs">清空</el-button>
          <el-button type="text" :icon="visible ? ArrowDownBold : ArrowUpBold"  @click="pickUp">{{ visible ? '收起' : '展开' }}</el-button>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>
<script setup lang="ts">
import { ArrowDownBold, ArrowUpBold } from '@element-plus/icons-vue'
import { AFold } from '@/utils/utils'
import { getCurrentInstance } from 'vue'
import { ref } from 'vue'
const value = ref('')
const memberList = [
  {
    value: '2',
    label: '是'
  },
  {
    value: '1',
    label: '否'
  }
]
const memberType = [
  {
    value: '0',
    label: '企微'
  },
  {
    value: '1',
    label: '非企微'
  }
]
const memberStatus = [
  {
    value: '1',
    label: '已激活'
  },
  {
    value: '2',
    label: '已禁用'
  },
  {
    value: '4',
    label: '未激活'
  },
  {
    value: '5',
    label: '退出企业'
  }
]
defineProps(['formInline'])
const internalInstance = getCurrentInstance()
const emit = defineEmits({
  searchChange: null,
  clearSearch: null,
  getTableH: null
})
const visible = ref(true)
const pickUp = () => {
  visible.value = !visible.value
  AFold(visible.value, '.el_filter_row')
  emit('getTableH')
}
const onSubmit = (formName: string) => {
  const { is_follow_user, status, is_local, name } = internalInstance?.proxy?.[formName]
  emit('searchChange', {
    is_follow_user,
    status,
    is_local,
    name
  })
}
const clearSearchs = () => {
  emit('clearSearch')
}
</script>
<style lang="scss" scoped>
.zw-search-form {
  padding: 16px;
  margin-bottom: 16px;
  background-color: #f9f9f9;
  .el-row {
    display: flex;
    flex-wrap: wrap;
    position: relative;
    box-sizing: border-box;
    margin: -8px -10px;
    .el-col {
      margin: 8px 0;
      &:last-of-type {
        flex: auto;
        text-align: right;
      }
      .el-form-item {
        margin-bottom: 0;

        .el-form-item__label-wrap {
          .el-form-item__label {
            font-size: 14px;
            font-family: STHeitiSC-Light, STHeitiSC;
            font-weight: 300;
            color: #33302d;
          }
        }

        .el-form-item__content {
          .el-input,
          .el-select,
          .el-date-editor {
            width: 100%;
          }
        }
      }
    }
  }
}
</style>
